﻿@using Seal.Model
@using Seal.Helpers
@{
    ReportView view = Model;
    ReportModel reportModel = view.Model;
    Report report = view.Report;
}

<table @Raw(view.AddAttribute("class", "summary_table_class")) @Raw(view.AddAttribute("style", "summary_table_css"))>
    @if (view.HasValue("summary_table_caption"))
    {
        <caption @Raw(view.AddAttribute("style", "summary_table_caption_css"))>@Raw(view.GetHtmlValue("summary_table_caption"))</caption>
    }
    <thead>
        @for (int row = 0; row < 1; row++)
        {
            <tr  @Raw(view.AddAttribute("class", "summary_header_class")) @Raw(view.AddAttribute("style", "summary_header_css"))>
                @for (int col = 0; col < reportModel.SummaryTable.ColumnCount; col++)
                {
                    ResultCell cell = reportModel.SummaryTable[row, col];
                    if (!view.GetBoolValue("display_summary_totals") && cell.IsTotal) { continue; }
                    <th @Raw(Helper.AddAttribute("class", cell.CellCssSummaryClass)) @Raw(Helper.AddAttribute("style", cell.CellCssSummaryStyle.Replace("padding-right:25px;", "padding-right:8px;"))) @Raw(reportModel.GetNavigation(view, cell))>
                        @Raw(cell.HTMLValue)
                    </th>
                }
            </tr>
        }
    </thead>
    <tbody>
        @for (int row = reportModel.SummaryTable.BodyStartRow; row < reportModel.SummaryTable.BodyEndRow; row++)
        {
            <tr @Raw(view.AddAttribute("class", "summary_body_class")) @Raw(view.AddAttribute("style", "summary_body_css"))>
                @for (int col = 0; col < reportModel.SummaryTable.ColumnCount; col++)
                {
                    ResultCell cell = reportModel.SummaryTable[row, col];
                    if (!view.GetBoolValue("display_summary_totals") && cell.IsTotal) { continue; }
                    <td @Raw(Helper.AddAttribute("class", cell.CellCssSummaryClass)) @Raw(Helper.AddAttribute("style", cell.CellCssSummaryStyle)) @Raw(reportModel.GetNavigation(view, cell))>
                        @Raw(cell.HTMLValue)
                    </td>
                }
            </tr>
        }
    </tbody>
    @if (view.GetBoolValue("add_summary_totals_totals") && view.GetBoolValue("display_summary_totals") && reportModel.HasTotals)
    {
        <tfoot>
            @for (int row = reportModel.SummaryTable.BodyEndRow; row < reportModel.SummaryTable.RowCount; row++)
            {
                <tr @Raw(view.AddAttribute("class", "summary_footer_class")) @Raw(view.AddAttribute("style", "summary_footer_css"))>
                    @for (int col = 0; col < reportModel.SummaryTable.ColumnCount; col++)
                    {
                        ResultCell cell = reportModel.SummaryTable[row, col];
                        if (!view.GetBoolValue("display_summary_totals") && cell.IsTotal) { continue; }
                        <td @Raw(Helper.AddAttribute("class", cell.CellCssSummaryClass)) @Raw(Helper.AddAttribute("style", cell.CellCssSummaryStyle).Replace("padding-right:25px;", "padding-right:8px;")) @Raw(reportModel.GetNavigation(view, cell))>
                            @Raw(cell.HTMLValue)
                        </td>
                    }
                </tr>
            }
        </tfoot>
    }
</table>

@if (view.GetBoolValue("show_page_separator"))
{
    <hr style="display: block;" />
}

